<?php
/**
 * [模型]订单
 * 
 * @version $Id: Order.php 286 2012-05-02 06:00:59Z linsir123 $
 */
class modelOrder 
{
	/**
	 * @var 数据模型
	 */
	public $dbOrder;
	
	/**
	 * @var 会员ID
	 */
	public $uId = 0;
	
	/**
	 * 构造函数
	 */
	public function __construct()
	{
		$this->dbOrder = D::order();
	}
	
	/**
	 * 取得"订单模块"的相关信息
	 * // 订单数, 总返现金额, 简单订单
	 */
	public function getInfo()
	{
		$count = intval($this->dbOrder->getOrdersCountByUser($this->uId));
		$commission = round($this->dbOrder->getOrdersMoneyByUser($this->uId), 2);
		
		///
		return array(
			'count' => $count,
			'commission' => $commission,
			'list' => $this->getList(0, 5),
		);
	}
	
	/**
	 * 取得列表
	 */
	public function getList($start, $offset, $params = array())
	{
		$params['uid'] = $this->uId;
		
		///
		return $this->dbOrder->getList($start, $offset, $params);
	}
	
	/**
	 * 取得个数
	 */
	public function getListCount($params = array())
	{
		$params['uid'] = $this->uId;
		
		///
		return $this->dbOrder->getListCount($params);
	}
}
